package zumyi12;

/**
 * 数据类
 */
public class Data {
    //数组类型对象的创建
    static Car [] car = new Car[4];
    static Bus [] bus = new Bus[4];

    public static void init() {
        car[0] = new Car("宝马", "x6", "京NY28588", 800);
        car[1] = new Car("宝马", "550i", "京CNY3284", 600);
        car[2] = new Car("别克", "林荫大道", "京NT37465", 300);
        car[3] = new Car("别克", "GL8", "京NT96968", 600);

        bus[0] = new Bus("金杯", "京6566754", 16, 800);
        bus[1] = new Bus("金龙", "京8696997", 16, 800);
        bus[2] = new Bus("金杯", "京9696996", 34, 1500);
        bus[3] = new Bus("金龙", "京8696998", 34, 1500);
    }

    //租轿车（通过品牌和类型就可以知道用户选择的哪辆轿车）
    public static Car rentCar(String brand,String model){
        Car c = null;
        for (Car car:car) {
            if (car.getBrand().equals(brand)&&car.getModel().equals(model)){
                c=car;
                break;
            }
        }
        return c;//返回给用户一轿车
    }
    //租客车（通过品牌和座位数就可以判断用户选择的哪辆客车）
    public static Bus rentBus(String brand,int seatNumber){
        Bus b = null;
        for (Bus bus:bus) {
            if (bus.getBrand().equals(brand)&&bus.getSeatNumbet()==seatNumber){
                b=bus;
                break;
            }
        }
        return b;//返回给用户一辆客车
    }
}